<div class="container">
    <h1 id="pkg-overview">package format</h1>
    <p><code>import "go/format"</code>
    </p><p>Package format implements standard formatting of Go source.。</p>
    
    
		
        
        
    
    
    <h2 id="Node">func Node </h2>
    <pre>func Node(dst <a href="./io.htm">io</a>.<a href="./io.htm#Writer">Writer</a>, fset *<a href="./go_token.htm">token</a>.<a href="./go_token.htm#FileSet">FileSet</a>, node interface{}) <a href="./builtin.htm#error">error</a></pre>
    <p>
Node formats node in canonical gofmt style and writes the result to dst.
</p>
<p>
The node type must be *ast.File, *printer.CommentedNode, []ast.Decl,
[]ast.Stmt, or assignment-compatible to ast.Expr, ast.Decl, ast.Spec,
or ast.Stmt. Node does not modify node. Imports are not sorted for
nodes representing partial source files (i.e., if the node is not an
*ast.File or a *printer.CommentedNode not wrapping an *ast.File).
</p>
<p>
The function may return early (before the entire result is written)
and return a formatting error, for instance due to an incorrect AST.
</p>

    <h2 id="Source">func Source </h2>
    <pre>func Source(src []<a href="./builtin.htm#byte">byte</a>) ([]<a href="./builtin.htm#byte">byte</a>, <a href="./builtin.htm#error">error</a>)</pre>
    <p>
Source formats src in canonical gofmt style and returns the result
or an (I/O or syntax) error. src is expected to be a syntactically
correct Go source file, or a list of Go declarations or statements.
</p>
<p>
If src is a partial source file, the leading and trailing space of src
is applied to the result (such that it has the same leading and trailing
space as src), and the result is indented by the same amount as the first
line of src containing code. Imports are not sorted for partial source files.
</p>
</div>